#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int m, t = 0, s = 0, n, a[110], b[110], c[110], d[110];
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i] >> b[i];
		c[i] = a[i];
		d[i] = b[i];
	}
	if (n == 1)
	{
		cout << "(" << a[1] << "," << b[1] << ")";
	}
	else
	{
		sort(a + 1, a + n + 1);
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 1; j <= n; ++j)
			{
				if (a[i] == c[j])
				{
					b[i] = d[j];
					c[j] = 0;
					break;
				}
			}
		}
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 1; j <= n; ++j)
			{
				if (a[i] >= a[j] && b[i] >= b[j])
				{
					if (a[i] == a[j] && b[i] == b[j])
					{
						continue;
					}
					else
					{
						a[j] = 0;
						b[j] = 0;
					}
				}
			}
		}
		for (int i = 1; i <= n; ++i)
		{
			if (a[i] > 0 || b[i] > 0)
			{
				s++;
			}
		}
		if (s == 1)
		{
			for (int i = 1; i <= n; ++i)
			{
				if (a[i] > 0 || b[i] > 0)
				{
					cout << "(" << a[i] << "," << b[i] << ")";
					break;
				}
			}
		}
		else
		{
			for (int j = 1; j <= n; ++j)
			{
				if (a[j] == 0 && b[j] == 0)
				{
					continue;
				}
				else
				{
					cout << "(" << a[j] << "," << b[j] << ")" << ",";
					t++;
				}
				if (t == s - 1)
				{
					m = j;
					break;
				}
			}
			for (int i = m + 1; i <= n; ++i)
			{
				if (a[i] == 0 && b[i] == 0)
				{
					continue;
				}
				else
				{
					cout << "(" << a[i] << "," << b[i] << ")";
				}
			}
		}
	}
	return 0;
}
